712C - Memory and De-Evolution - CodeForces Solution


greedy math *1600

Please click on ads to support us..

Python Code:

import math
 
alfabet = {'a': 1, 'b': 2,'c': 3,'d': 4,'e': 5,'f': 6,'g': 7,'h': 8,'i': 9,'j': 10,'k': 11,'l': 12,'m': 13,'n': 14,'o': 15,'p': 16,'q': 17,'r': 18,'s': 19,'t': 20,'u': 21,'v': 22,'w': 23,'x': 24,'y': 25,'z': 26}
alfabet_2={'1':"a", '2':"b", '3':"c", '4':"d", '5':"e", '6':"f", '7':"g", '8':"h", '9':"i", '10':"j", '11':"k", '12':"l", '13':"m", '14':"n", '15':"o", '16':"p", '17':"q", '18':"r", '19':"s", '20':"t", '21':"u", '22':"v", '23':"w", '24':"x", '25':"y", '26':"z"}
 
 
def transformare_baza(numar,baza):
 
 transformare=""
 while numar>=baza:
  rest=numar%baza
  numar=numar//baza
  transformare+=str(rest)
 
 transformare+=str(numar)
 noua_baza=transformare[::-1]
 return noua_baza
 
 
def functie_string_baza(stringul,baza):
 answ=0
 stringul=stringul.lower()
 lungime=len(stringul)
 for j in range(lungime):
  if stringul[j] in alfabet:
   answ+=(baza**(lungime-1-j))*(alfabet[stringul[j]]+9)
  else:
      answ+=(baza**(lungime-1-j))*(int(stringul[j]))
  
 return (answ)
 
from decimal import *
 
for contorr in range(1):
 
 x,y=list(map(int, input().split()))
 
 if y==x:
  print(0)
 else:
  
  minimul=min(x,y)
  maximul=max(x,y)
  cate=0
  
  lista=[0]*3
  lista[0]=minimul
  lista[1]=minimul
  lista[2]=minimul
  
  while lista[0]!=maximul or lista[1]!=maximul or lista[2]!=maximul:
   lista.sort()
   lista[0]=min(maximul,lista[1]+lista[2]-1)
   cate+=1
  print(cate)  
  
   
    
    
   
 


Comments

Submit
0 Comments
More Questions

32B - Borze
1651B - Prove Him Wrong
381A - Sereja and Dima
41A - Translation
1559A - Mocha and Math
832A - Sasha and Sticks
292B - Network Topology
1339A - Filling Diamonds
910A - The Way to Home
617A - Elephant
48A - Rock-paper-scissors
294A - Shaass and Oskols
1213A - Chips Moving
490A - Team Olympiad
233A - Perfect Permutation
1360A - Minimal Square
467A - George and Accommodation
893C - Rumor
227B - Effective Approach
1534B - Histogram Ugliness
1611B - Team Composition Programmers and Mathematicians
110A - Nearly Lucky Number
1220B - Multiplication Table
1644A - Doors and Keys
1644B - Anti-Fibonacci Permutation
1610A - Anti Light's Cell Guessing
349B - Color the Fence
144A - Arrival of the General
1106A - Lunar New Year and Cross Counting
58A - Chat room